<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>后台管理--菜单列表</title>
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet"/>
    <link href="${ctxStatic}/ligeruilib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
    <link href="${ctxStatic}/css/kpiui.css" rel="stylesheet"/>
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js" type="text/javascript"></script>
    <%--<script src="${ctxStatic}/js/formSelects-v4.js" type="text/javascript"></script>--%>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="${ctxStatic}/js/common.js" type="text/javascript"></script>


    <style>
        .pdf > table {
            width: 100%;
            font-size: .938em;
            border-collapse: collapse; /*边框会合并为一个单一的边框*/
        }

        .pdf th {
            text-align: left;
            padding: .5em .5em;
            font-weight: bold;
            background: #66677c;
            color: #fff;
        }

        .pdf td {
            padding: .5em .5em;
            border-bottom: solid 1px #ccc;
        }

        .pdf table, .pdf table tr th, .pdf table tr td {
            border: 1px solid #0094ff;
        }

        .layui-form-checkbox[lay-skin=primary] span{

             color: white;
        }
        /*设置边框的*/
    </style>

</head>
<body>


<div class="serchcontent" style="margin:10px">
    <div class="search" style="    margin-top: 10px;   margin-left: 30px">
        <div class="layui-form">
            <table nostyle="true">
                <tr>
                    <td><input type="text" name="start_time" class="layui-input" id="start_time"
                               placeholder="开始时间(修改时间)"></td>
                    <td> <input type="text" name="end_time" class="layui-input" id="end_time"
                                placeholder="结束时间(修改时间)"></td>
                    <td>
                    <input type="text" id="orgid"   class="layui-input">
                    <input type="hidden" id="hidorgid"  name="orgid" value="">
                    </td>
                    <td>
                        <div class="layui-form-item" style="margin-top: 12px ">
                            <div class="layui-unselect layui-form-select downpanel cs">
                                <div class="layui-select-title">
                                    <input type="text" placeholder="请选择考勤类型" value="" readonly="" class="layui-input layui-unselect"><i class="layui-edge"></i>
                                </div>
                                <dl class="layui-anim layui-anim-upbit">
                                    <dd><input type="checkbox" name="brand" title="所有" value="00" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="年休假" value="1" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="探亲假" value="2" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="婚嫁" value="3" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="生育假" value="4" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="丧假" value="5" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="因公致伤" value="6" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="病假" value="7" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="事假" value="8" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="其他" value="9" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="迟到" value="10" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="早退" value="11" lay-skin="primary" ></dd>
                                    <dd><input type="checkbox" name="brand" title="旷工" value="12" lay-skin="primary" ></dd>
                                </dl>
                            </div>
                        </div>
                    </td>
                    <td>姓名：</td>
                    <td style="width:120px"><input type="text" style="width:120px" class="text"
                                                   id="realname"/></td>
                    <td>
                        <input type="button" class="button" value="查询" onclick="search()"/>
                        <input type="button" class="button" value="导出" onclick="excleport()"/>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>

<div class="content" style="margin-left: 20px">

    <table class="layui-table fc-view-container" lay-data="" lay-filter="attbmhzlist" id="attbmhzlist">
        <thead>
        <tr>
            <th lay-data="{field:'rowNum', width:60,align:'center',fixed: 'left'}" rowspan="2">序号</th>
            <th lay-data="{field:'realname', width:120,align:'center',fixed: 'left',templet: '#realnameTpl'}"
                rowspan="2">
                姓名
            </th>
            <th lay-data="{field:'cardno', width:200,align:'center',event:'glxs', style:'cursor: pointer;'}"
                rowspan="2">
                身份证号
            </th>
            <th lay-data="{field:'orgname', width:200,align:'center',event:'glxs', style:'cursor: pointer;'}"
                rowspan="2">
                实际工作单位
            </th>
            <th lay-data="{field:'rsgxorgname', width:200,align:'center',event:'glxs', style:'cursor: pointer;'}"
                rowspan="2">人事关系所在单位
            </th>
            <th lay-data="{field:'year', width:80,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">年份
            </th>
            <th lay-data="{field:'mouth', width:80,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">
                月份
            </th>

            <!--<th lay-data="{field:'sfqq', width:100,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">是否全勤</th>-->
            <!--<th lay-data="{field:'jbts', width:100,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">加班天数</th>  -->
            <th lay-data="{field:'sfjb', width:100,align:'center',templet: '#sfjbTpl'}" rowspan="2">是否加班</th>
            <th lay-data="{align:'center'}" colspan="10">未 出勤天数</th>
            <th lay-data="{field:'cdcc', width:80,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">迟到
            </th>
            <th lay-data="{field:'ztcc', width:80,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">早退
            </th>
            <th lay-data="{field:'kgcs', width:80,align:'center',event:'glxs', style:'cursor: pointer;'}" rowspan="2">旷工
            </th>
            <th lay-data="{field:'remark', width:120,align:'center',event:'glxs', style:'cursor: pointer;'}"
                rowspan="2">
                备注
            </th>
        </tr>
        <tr>
            <th lay-data="{field:'wcqtsxj', width:80,align:'center',templet: '#wcqtsxjTpl',event:'glxs', style:'cursor: pointer;'}">
                小计
            </th>
            <th lay-data="{field:'xjts', width:100,align:'center',templet: '#xjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                年休假
            </th>
            <th lay-data="{field:'tqjts', width:100,align:'center',templet: '#tqjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                探亲假
            </th>
            <th lay-data="{field:'hjts', width:80,align:'center',templet: '#hjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                婚假
            </th>
            <th lay-data="{field:'syjts', width:100,align:'center',templet: '#syjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                生育假
            </th>
            <th lay-data="{field:'sangjts', width:80,align:'center',templet: '#sangjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                丧假
            </th>
            <th lay-data="{field:'gsts', width:100,align:'center',templet: '#gstsTpl',event:'glxs', style:'cursor: pointer;'}">
                因公致伤
            </th>
            <th lay-data="{field:'bjts', width:80,align:'center',templet: '#bjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                病假
            </th>
            <th lay-data="{field:'sjts', width:80,align:'center',templet: '#sjtsTpl',event:'glxs', style:'cursor: pointer;'}">
                事假
            </th>
            <th lay-data="{field:'qtts', width:80,align:'center',templet: '#qttsTpl',event:'glxs', style:'cursor: pointer;'}">
                其他
            </th>
        </tr>
        </thead>
    </table>

    <script type="text/html" id="realnameTpl">
        <span class="dbclickspan" ondblclick="OpenUserInfo({{ d.userid }},'{{ d.realname }}')"> {{ d.realname }}<span>
    </script>
    <script type="text/html" id="sfjbTpl">
        {{#  if(d.sfjb==0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">否</span>
        {{#  } else { }}
        是
        {{#  } }}
    </script>

    <script type="text/html" id="wcqtsxjTpl">
        {{#  if(d.wcqtsxj>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.wcqtsxj }}</span>
        {{#  } else { }}
        {{ d.wcqtsxj }}
        {{#  } }}
    </script>

    <script type="text/html" id="xjtsTpl">
        {{#  if(d.xjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.xjts }}</span>
        {{#  } else { }}
        {{ d.xjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="tqjtsTpl">
        {{#  if(d.tqjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.tqjts }}</span>
        {{#  } else { }}
        {{ d.tqjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="hjtsTpl">
        {{#  if(d.hjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.hjts }}</span>
        {{#  } else { }}
        {{ d.hjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="syjtsTpl">
        {{#  if(d.syjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.syjts }}</span>
        {{#  } else { }}
        {{ d.syjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="sangjtsTpl">
        {{#  if(d.sangjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.sangjts }}</span>
        {{#  } else { }}
        {{ d.sangjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="gstsTpl">
        {{#  if(d.gsts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.gsts }}</span>
        {{#  } else { }}
        {{ d.gsts }}
        {{#  } }}
    </script>

    <script type="text/html" id="bjtsTpl">
        {{#  if(d.bjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.bjts }}</span>
        {{#  } else { }}
        {{ d.bjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="sjtsTpl">
        {{#  if(d.sjts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.sjts }}</span>
        {{#  } else { }}
        {{ d.sjts }}
        {{#  } }}
    </script>

    <script type="text/html" id="qttsTpl">
        {{#  if(d.qtts>0){ }}
        <span style="color: rgba(255,186,0,1);font-weight:bold;">{{ d.qtts }}</span>
        {{#  } else { }}
        {{ d.qtts }}
        {{#  } }}
    </script>
</div>

</body>
<script>
    var _table;
    var _param = [];
    var _form;
    var _click = 0;
    $(function () {

        initForm();
        InitOrg();
        getdata();
        initTable(_param.start, _param.entt, _param.orgid,_param.atttype,"");

    })

    function initForm() {
        layui.use('form', function () {
            form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功


            form.render();
            _form = form;
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            var nowTime = new Date().valueOf();
            var max = null;

            var start = laydate.render({
                elem: '#start_time',
                type: 'month',
                // range: true,
                max: nowTime,
                 value:new Date().format('yyyy-MM'),
                btns: ['clear', 'confirm'],
                done: function(value, date){
                    endMax = end.config.max;
                    end.config.min = date;
                    end.config.min.month = date.month -1;
                }
            });
            var end = laydate.render({
                elem: '#end_time',
                type: 'month',
                value:new Date().format('yyyy-MM'),
                // range: true,
                done: function(value, date){
                    if($.trim(value) == ''){
                        var curDate = new Date();
                        date = {'date': curDate.getDate(), 'month': curDate.getMonth()+1, 'year': curDate.getFullYear()};
                    }
                    start.config.max = date;
                    start.config.max.month = date.month -1;
                }
             });
        });

        layui.use(['layer','jquery','form','element','util'], function(){
            var layer = layui.layer,form = layui.form,element = layui.element,util = layui.util,$=layui.jquery;
            $(function(){

                //    //遍历渲染 不建议用
                //    $("select.downlist").each(function(index,item) {
                //        var $this=$(this);
                //        var $select=$this.next(".layui-form-select");
                //        $select.addClass("downpanel");
                //        var $dl=$select.find("dl");
                //        $(".layui-select-title input",$select).val($this.attr("placeholder"));
                //        $dl.empty();
                //        var str="";
                //        $("option",$this).each(function() {
                //            str=["<dd>","<input class='sk' type='checkbox' name='brand[",$(this).val(),"]' lay-skin='primary' title='",$(this).text(),"' value='true'>","</dd>"].join("");
                //            $dl.append(str);
                //        });
                //        form.render("checkbox");
                //
                //    });
                $(".downpanel").on("click",".layui-select-title",function(e){
                     _click =_click + 1;
                     console.log(_click);
                    var $select=$(this).parents(".layui-form-select");

                    $(".layui-form-select").not($select).removeClass("layui-form-selected");
                    if(_click%2 ==0){
                        $select.addClass("layui-form-selected");
                    }else
                    {
                        $select.toggleClass("layui-form-selected");
                    }
                    e.stopPropagation();
                }).on("click",".layui-form-checkbox",function(e){
                    e.stopPropagation();
                });
            });
        });
    }


    function getdata() {
        var id_array=[];
        $("input:checkbox[name='brand']:checked").each(function() {
            id_array.push($(this).val());//向数组中添加元素
        });
        var idstr=id_array.join(',');//将数组元素连接起来以构建一个字符串
        //
        // var formSelects = layui.formSelects;
        // console.log(formSelects);

        console.log( $("#orgid").val());
        _param['start'] = $("#start_time").val();
        _param['endt'] = $("#end_time").val();
        _param['orgid'] =  $("#hidorgid").val();
        _param['atttype'] =  idstr;
        _param['realname'] = $("#realname").val();
    }

    function InitOrg() {
            var comboboxm=$("#orgid").ligerComboBox({
                valueField : 'orgid',
                textField : 'orgname',
                selectBoxWidth : 250,
                selectBoxHeight:250,
                treeLeafOnly:false,
                valueFieldID:"hid",
                tree: {url : '../common/get_org_list?orgtype=0',
                    checkbox: false,
                    nodeWidth:150,
                    ajaxType: 'get',
                    idFieldName: 'orgid',
                    textFieldName:"orgname",
                    idField:"orgid",
                    parentIDField:"orgparentid"
                },
                onSelected : function(orgid, orgname) {// id为空值，name为选择的值
                    $("#hidorgid").val(orgid);
                    // searchtable();
                },
                width : 250
            });
            return comboboxm;
        }

    function initTable(start, endt, orgid,atttype,realname) {
        layui.use('table', function () {
            table = layui.table;
            table.init('attbmhzlist', {
                height: $(window).height() - 100
                , url: 'get_cx_list' // 数据接口
                , page: true // 开启分页
                , limit: 40
                , id: 'attbmhzlist'
                , limits: [20, 40, 80, 100]
                , method: "post"
                , request: {
                    type: 'post'
                }
                , where: {
                    start: start ,
                    endt: endt ,
                    orgid: orgid,
                    atttype:atttype,
                    realname: realname
                }
                , done: function (res, page, count) {

                    var dataarr = res.data;
                    $("[data-field='status']").children().each(function (index) {
                        if (index > 0) {
                            var text = $(this).text();
                            switch (text) {
                                case null:
                                    $(this).text("未填报");
                                    break;
                                case '':
                                    $(this).text("未填报");
                                    break;
                                case '0':
                                    $(this).text("填报");
                                    break;
                                case '1':
                                    $(this).text("提交");
                                    break;
                                case '2':
                                    $(this).text("归档");
                                    break;
                                case '3':
                                    $(this).text("驳回");
                                    break;
                            }
                        }
                    })


                    $("[data-field='sfqq']").children().each(function (index) {
                        if (index > 0) {
                            var text = $(this).text();
                            if (text == "0") {
                                $(this).text("否");
                            }
                            else {
                                $(this).text("是");
                            }
                        }
                    })
                }
            });

            //监听工具条
            table.on('tool(attbmhzlist)', function (obj) {
                var data = obj.data;
                if (obj.event === 'detail') {
                    vAttBmHz.openadddetail(obj.data.attsummaryid, obj.data.orgsummaryid);
                }
            });

            _table = table;
        })
    }

    function search() {
        getdata();
        _table.reload('attbmhzlist', {
            page: {
                curr: 1 //重新从第 1 页开始
            }
            ,
            where: {
                start: _param.start ,
                endt: _param.endt ,
                orgid: _param.orgid,
                atttype:_param.atttype,
                realname: _param.realname
            }
        })
    }

    function excleport() {
        getdata();
        top.ShowZheZhao();
        $.ajax({
            type: "POST",
            url: "export_ck_excel",
            data: {
                start: _param.start ,
                endt: _param.endt ,
                orgid: _param.orgid,
                atttype:_param.atttype,
                realname: _param.realname
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = eval('(' + data + ')');
                if (data.result > 0) {
                    //top.mylayui.msg(data.msg, {icon: 1});
                    //alert(data.msg);
                    window.open(data.msg, '_self');
                }
                else {
                    top.mylayui.msg(data.msg, {icon: 0});
                }
                top.ShowZheZhao();

            },
            complete: function (XHR) {
                top.mylayui.closeAll('loading');
            },
            error: function () {

            }
        });
    }
    

</script>
</html>
